<?php
class Param extends Controller {

	function Param()
	{
		parent::Controller();

		//thanks to this line of code you can protect this controller
		$this->authlib->check();
	}
	//----------------------------------------------------------------------
	function index()
	{
		echo '<h1>You can view this message because you logged in and are at least an user!</h1>';
	}
	
	function get($id)
	{
		$this->load->model('Systemparam');
		// Load the mime types
		@include(APPPATH.'config/mimes'.EXT);

		header("Content-Type: {$mimes['xml']};");
		header("Cache-Control: no-cache, must-revalidate");
		header("Pragma: no-cache");
		
		$output = '<?xml version="1.0" encoding="UTF-8" ?>';
		$data = $this->Systemparam->getParamByParentId($id);
		$output .= "<Param><Count>" . count($data) . "</Count>";
		foreach ($data as $item)
		{
			$output .= "<Item><id>{$item->id}</id><sort>{$item->SortNo}</sort><layer>{$item->layer}</layer><name>{$item->TreeView_Name}</name></Item>";
		}
		$output .= '</Param>';

		$this->output->set_output($output);
	}
}
?>